#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool hasAlternatingBits(int n) {
    long a = n ^ (n >> 1);
    return (a & (a + 1)) == 0;
}

bool hasAlternatingBits(int n) {
    int d = n & 1; n >>= 1;
    while(n != 0){
        if((n&1)^(!d)) return false;
        d = !d; n >>= 1;
    }
    return true;
}

int main(){
    int n = 5;
    cout << hasAlternatingBits(n) << endl;
    return 0;
}
